const cloud = require('@alipay/faas-server-sdk');
const db = cloud.database();
exports.main = async (event, context) => {
  //查询购物车明细
  const shopCarList = await cloud.callFunction({
    name: 'shopCarList',
    data: {
      userId:event.userId
    }
  });
  const shopList = shopCarList.result;
  console.log('shopList result:', shopList);
  const ids = shopList.map(item => item._id);
  //遍历购物车列表，清空购物车数据
  const shopCarResponse = await cloud.callFunction({
    name: 'shopCarDelete',
    data: {
      ids: ids
    }
  });
  return shopCarResponse;
};